package com.dk.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dk.mapper.ModelsMapper;
import com.dk.pojo.Tbmodels;
import com.dk.pojo.Tbseries;
import com.dk.pojo.Tbsubscribe;
import com.dk.service.ModelsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ModelsServiceimpl implements ModelsService {
    @Autowired
    private ModelsMapper modelMapper;
    @Override
    public List<Tbmodels> getModels(String yearsId) {
        /*java8新特性 方法的引用*/
        LambdaQueryWrapper<Tbmodels> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<Tbmodels> eq = lambdaQueryWrapper.eq(!StringUtils.isEmpty(yearsId),Tbmodels:: getYearsId, yearsId);
        List<Tbmodels> tbseries = modelMapper.selectList(eq);
        return tbseries;
    }

    @Override
    public Tbmodels getModel(String modelsId) {
        LambdaQueryWrapper<Tbmodels> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<Tbmodels> eq = lambdaQueryWrapper.eq(!StringUtils.isEmpty(modelsId),Tbmodels:: getModelsId, modelsId);
        Tbmodels tbmodels = modelMapper.selectOne(eq);
        return tbmodels;
    }
}
